<?php


namespace app\common\validate;


use think\Validate;

class Admin extends Validate
{
    //需要校验的字段
    protected $rule=[
        'username|管理员账户'=>'require',
        'password|管理员密码'=>'require',
        'nickname|昵称'=>'require',
        'email|邮箱'=>'require|email',
    ];
    //登录验证场景-创建validate目录和校验php
    public function sceneLogin()
    {
        return $this->only(['username','password']);
    }
    //注册验证场景-创建validatemul和校验的php
    public function sceneRegister()
    {
        return $this->only(['username','password','nickname','email'])
            ->append('username','unique:admin'); //判断用户是否已经注册校验
    }
}